import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../../viewmodel/MainPageViewModel.dart';

class MatchPage extends StatefulWidget {
  const MatchPage({super.key});

  @override
  State<MatchPage> createState() => _MatchPageState();
}

class _MatchPageState extends State<MatchPage> {
  final _mainPageViewModel = MainPageViewModel();

  void _gg() {
    // var firstLevelCategory = FirstLevelCategory(name: "xcxcx");
    // DatabaseHelper().insert(FirstLevelCategory(name: "xcxcx"));
    //
    setState(() {});
  }

  @override
  void initState() {
    super.initState();
    name();
  }
  Future<void> name() async {
    await _mainPageViewModel.getALLOneCategory();
    setState(() {});
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.builder(
        itemBuilder: (context, index) {
          return ListTile(
              onTap: () {
                _gg();
              },
              title: Text(
                  "${_mainPageViewModel.firList[index].name} ... ${_mainPageViewModel.firList[index].id}"));
        },
        itemCount: _mainPageViewModel.firList.length,
      ),
    );
  }
}
